import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Test11 {

    public static int[] findIntersectionValues(int[] nums1, int[] nums2) {

        int[] arr = new int[2];
        int answer1 = 0;
        int answer2 = 0;
        Set<Integer> set1 = new HashSet<>();
        Set<Integer> set2 = new HashSet<>();
        for(int i = 0;i<nums1.length;i++){
            set1.add(nums1[i]);
        }
        for(int i = 0;i<nums2.length;i++){
            set2.add(nums2[i]);
        }
        for(int i = 0;i<nums1.length;i++){
            boolean flag =  set2.add(nums1[i]);
            if(flag==true){
                set2.remove(nums1[i]);
            }
            else{
                answer1++;
            }
        }
        for(int i = 0;i<nums2.length;i++){
            boolean flag =  set1.add(nums2[i]);
            if(flag==true){
                set2.remove(nums2[i]);
            }
            else{
                answer2++;
            }

        }
        arr[0] = answer1;
        arr[1] = answer2;
        return arr;
    }

    public static void main(String[] args) {
        int[] arr = new int[]{10,30,16,18};
        int[] acc = new int[]{23,30,30,6,10,26,9,27,6,16,18,10,27,2,20,7,16};
       arr= findIntersectionValues(arr,acc);
        System.out.println(Arrays.toString(arr));
    }
}
